﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;

namespace Webfrom
{
    public class DbHelper
    {
        private static readonly string connectionString = "server=.;database=Bank;uid=sa;pwd=123456;";

        public static DataTable GetDataTable (string sql)
        {
            SqlDataAdapter adapter = new SqlDataAdapter(sql,connectionString);
            DataTable data = new DataTable();
            adapter.Fill(data);
            return data;
        }
        public static int AddOrUpdateOrDelete(string sql)
        {
            SqlConnection connection = new SqlConnection(connectionString);
            SqlCommand command = new SqlCommand(sql,connection);
            connection.Open();
            var res = command.ExecuteNonQuery();
            connection.Close();
            return res;
        }
    }
}